import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class Servlet2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        Object school=req.getAttribute("school");
        resp.setContentType("text/html;charset=utf-8");
        if(school==null){
            resp.getWriter().write("你是从浏览器直接访问servlet2");
        }else{
            resp.getWriter().write((String)school);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
